package client_package;

import java.io.BufferedReader;
import java.io.IOException;

import client_package.Controleur.StatutSound;

public class ThreadRecevoirLaMain implements Runnable {
	private BufferedReader in_confirm;
	private Controleur c;
	
	public ThreadRecevoirLaMain(Controleur c, BufferedReader in_c) {
		this.c = c;
		this.in_confirm = in_c;
	}

	public void run() {
		while(!c.getStatutSound().equals(StatutSound.Pas_En_Communication)) {
			String ch = "";
			try {
				ch = in_confirm.readLine();
				if(ch.equals("fini")) {
					((VueConversation)c.getVue()).setPasserLaMain(true);
					c.setStatutSound(StatutSound.Enregistrement);
					c.setTSendRecord();
					c.getTSendRecord().start();
				} else if(ch.equals("quitter")) {
					c.setStatutSound(StatutSound.Pas_En_Communication);
					c.getOut_Confirm().println("fini");
					c.getOut_Confirm().flush();
					c.getOut_Confirm().println("finQuitter");
					c.getOut_Confirm().flush();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		//System.out.println("Je ferme threadRecevoirLaMain\n");
	}
}